<?php
	require '../config/config.php';
	$ConfigSql="select * from config where id='1'";
	$ConfigInfo=mysqli_query($con,$ConfigSql);
	$ConnfigRs=mysqli_fetch_array($ConfigInfo);
	session_start();
	if(empty($_SESSION['member'])){
	    echo "<script>location='../../index.php';</script>";
	    exit;
	}
	if($_GET['ops']=="logout"){
	    $_SESSION['member']="";
	    session_destroy();
	    echo "<script>alert('您已退出登录！');location='../index.php';</script>";
	}
	if(!empty($_GET['order'])){
	    if($_GET['ops']=="no"){
	        $bnoRs=mysqli_fetch_array(mysqli_query($con,"select * from orderRecord where bno='".$_GET['order']."'"));
        	if($bnoRs['user']==$_SESSION['member']){
        	    mysqli_query($con,"UPDATE `orderRecord` SET `state` = '-1' WHERE `bno` = '".$_GET['order']."'");
    	        echo "<script>alert('已作废此订单！');location='./order.php?order=".$_GET['order']."';</script>";
        	}else{
        	    echo "<script>alert('系统异常！');location='./index.php;</script>";    
        	}
	    }else{
	        $bnoRs=mysqli_fetch_array(mysqli_query($con,"select * from orderRecord where bno='".$_GET['order']."'"));
        	if($bnoRs['bno']=="" && $bnoRs['user']!=$_SESSION['member']){
        	    echo "<script>location='./index.php';</script>";
        	}
	    }
	}else{
	    echo "<script>location='./index.php';</script>";
	}
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title><?php echo $ConnfigRs['name'];?>-我的订单</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../css/head.css"/>
  <link rel="stylesheet" href="../layui/css/layui.css">

<link rel="stylesheet" href="../css/global.css">

<script src="../layui/layui.js"></script>
</head>
<body >

<div class="dvhead">
	<div class="dvlogo"><a href="index.php">你问我答</a></div>
	<div class="dvreg">
		<?php
		    if(empty($_SESSION['member'])){
                echo "已有账号，立即&nbsp;<a href='login.php'>登录</a>";
            }else{
                echo "欢迎您，".$_SESSION['member']." &nbsp;&nbsp;<a href='?ops=logout'> 退出</a>";
            }
		?>
	</div>
</div>

<div class="main layui-clear">
  <div class="fly-panel" pad20>
    <div class="layui-form layui-form-pane">
        <br />&nbsp;&nbsp;&nbsp;<a href="../index.php">首页</a> / <a href="../index.php">我的订单</a> / 订单明细<br /><br />
        <table class="news-edit">
		    <tr>
				<th>订单：</th>
				<td><?php echo $bnoRs['bno'];?></td>
			</tr>  
			<tr>
			    <th>金额：</th>
				<td><?php echo $bnoRs['total_amount'];?> HY币</td>
			</tr>
			<tr>
			    <th>名称：</th>
				<td><?php echo $bnoRs['subject'];?></td>
			</tr>
			<tr>
			    <th>明细：</th>
				<td><?php echo $bnoRs['more'];?></td>
			</tr>
			<tr>
			    <th>生成时间：</th>
				<td><?php echo $bnoRs['cdate'];?></td>
			</tr>
			<tr>
			    <th>支付时间：</th>
				<td><?php echo $bnoRs['pdate'];?></td>
			</tr>
			<tr>
			    <th>订单状态：</th>
				<td>
				    <?php 
				        if($bnoRs['state']=="-1"){
				            echo "已作废";
				        }elseif($bnoRs['state']=="0"){
				            echo "待支付 >>> <a href='./test.php?order=".$bnoRs['bno']."'>继续支付</a> | <a href='?order=".$bnoRs['bno']."&ops=no'>作废订单</a>";
				        }elseif($bnoRs['state']=="1"){
				            echo "已支付";
				        }elseif($bnoRs['state']=="2"){
				            echo "挂账";
				        }else
				    ?>
				</td>
			</tr>
			<tr>
			    <th>关联工单：</th>
				<td><a href="../show.php?id=<?php echo $bnoRs['feedbackid'];?>">查看工单</a></td>
			</tr>
		</table>
    </div>
  </div>
</div>

 <script type="text/javascript" charset="utf-8" src="js/kindeditor.js"></script>
  <script type="text/javascript">
    KE.show({
        id : 'content',
		resizeMode : 1,
        cssPath : './index.css',
        items : [
        'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
        'removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
        'insertunorderedlist', 'emoticons', 'image', 'link']
    });
  </script>
<script>

layui.cache.page = '';
layui.cache.user = {
  username: '游客'
  ,uid: -1
  ,avatar: '../res/images/avatar/00.jpg'
  ,experience: 83
  ,sex: '男'
};
layui.config({
  version: "2.0.0"
  ,base: '../res/mods/'
}).extend({
  fly: 'index'
}).use('fly');
</script>
</body>
</html>